
// source idl: com.erp.employee.ao.idl.EmployeeAo.java

#ifndef EMPLOYEEAO_STUB_4_APP_H
#define EMPLOYEEAO_STUB_4_APP_H

#include <string>
#include <sstream>
#include "app_platform/cmd_obj.h"
#include "c2cent/base/basestub4app.h"
#include "app_platform/cntl_info.h"
#include "app_platform/intf_serializable.h"
#include "app_platform/intf_service_object.h"
#include "erp/employee/po/employeepo_employee.h"	
#include "erp/employee/po/employeefilterpo_employee.h"	
#include <set>	
#include <map>	
#include "intf_employeeao.h"

namespace erp
{
namespace employee
{
namespace ao
{
	#define EMPLOYEEAO_STUB4APP_VERSION "ERP_EMPLOYEE_AO___EMPLOYEEAO__STUB4APP_VERSION__1.0 2013-10-18 14:07:59"
    const std::string EMPLOYEEAO_STUB4APP_NOUSE = EMPLOYEEAO_STUB4APP_VERSION;

	const uint32_t EMPLOYEEAO_ADDEMPLOYEE_REQ_CMD_ID = 0xC0011802; /// 请求命令号
	const uint32_t EMPLOYEEAO_ADDEMPLOYEE_RESP_CMD_ID = 0xC0018802; /// 回应命令号
	

	const uint32_t EMPLOYEEAO_GETEMPLOYEEBYID_REQ_CMD_ID = 0xC0011801; /// 请求命令号
	const uint32_t EMPLOYEEAO_GETEMPLOYEEBYID_RESP_CMD_ID = 0xC0018801; /// 回应命令号
	


	const uint16_t EMPLOYEEAO_MAX_PROTOCAL_VERSION = 2; //>平台支持的最大协议版本号

///////////////////////////// STRUCTS /////////////////////////////////////////////////
	/**
	 *
 	 * 
	 *
	 *
 	 * @date 2013-10-18 14:07:59
 	 * @version 0
	 */	
	struct CAddEmployeeReq : public IServiceObject, public ISerializableXML
	{
		std::string machineKey;
		std::string source;
		uint32_t sceneId;
		erp::employee::po::CEmployeePo employee;
		std::string inReserve;
		std::string errmsg;
		erp::employee::po::CEmployeePo employeeBack;
		std::string outReserve;
		
	    virtual uint32_t getCmdId() const { return EMPLOYEEAO_ADDEMPLOYEE_REQ_CMD_ID; }
		virtual bool Serialize(CByteStreamNetwork& bs)
		{
			//检查协议的版本号
		    //if(bs.getVersion() > EMPLOYEEAO_MAX_PROTOCAL_VERSION)
		    //return false;
			bs & machineKey;
			bs & source;
			bs & sceneId;
			employee.Serialize(bs);
			bs & inReserve;
		    return bs.isGood();
		}
	    virtual void Dump(std::ostream& os)	{}
	
		virtual bool FromXML(const std::string& sXMLContent) { return true; }
		virtual bool ToXML(std::string& sXMLContent) { return true; }
	};
	
	/**
	 *
 	 * 
	 *
 	 * @date 2013-10-18 14:07:59
 	 * @version 0
	 */	
	struct CAddEmployeeResp : public IServiceObject, public ISerializableXML
	{
		uint32_t dwResult;
		std::string errmsg;
		erp::employee::po::CEmployeePo employeeBack;
		std::string outReserve;
	
	    virtual uint32_t getCmdId() const { return EMPLOYEEAO_ADDEMPLOYEE_RESP_CMD_ID; }
		virtual bool Serialize(CByteStreamNetwork& bs)
		{
		    bs & dwResult;
			bs & errmsg;
			employeeBack.Serialize(bs);
			bs & outReserve;
		    return bs.isGood();
		}
	    virtual void Dump(std::ostream& os)	{}
	
		virtual bool FromXML(const std::string& sXMLContent) { return true; }
		virtual bool ToXML(std::string& sXMLContent) { return true; }
	};
	/**
	 *
 	 * 
	 *
	 *
 	 * @date 2013-10-18 14:07:59
 	 * @version 0
	 */	
	struct CGetEmployeeByIdReq : public IServiceObject, public ISerializableXML
	{
		std::string machineKey;
		std::string source;
		uint32_t sceneId;
		erp::employee::po::CEmployeeFilterPo employeeFilter;
		std::string inReserve;
		std::string errmsg;
		std::map<uint32_t,erp::employee::po::CEmployeePo > employees;
		std::string outReserve;
		
	    virtual uint32_t getCmdId() const { return EMPLOYEEAO_GETEMPLOYEEBYID_REQ_CMD_ID; }
		virtual bool Serialize(CByteStreamNetwork& bs)
		{
			//检查协议的版本号
		    //if(bs.getVersion() > EMPLOYEEAO_MAX_PROTOCAL_VERSION)
		    //return false;
			bs & machineKey;
			bs & source;
			bs & sceneId;
			employeeFilter.Serialize(bs);
			bs & inReserve;
		    return bs.isGood();
		}
	    virtual void Dump(std::ostream& os)	{}
	
		virtual bool FromXML(const std::string& sXMLContent) { return true; }
		virtual bool ToXML(std::string& sXMLContent) { return true; }
	};
	
	/**
	 *
 	 * 
	 *
 	 * @date 2013-10-18 14:07:59
 	 * @version 0
	 */	
	struct CGetEmployeeByIdResp : public IServiceObject, public ISerializableXML
	{
		uint32_t dwResult;
		std::string errmsg;
		std::map<uint32_t,erp::employee::po::CEmployeePo > employees;
		std::string outReserve;
	
	    virtual uint32_t getCmdId() const { return EMPLOYEEAO_GETEMPLOYEEBYID_RESP_CMD_ID; }
		virtual bool Serialize(CByteStreamNetwork& bs)
		{
		    bs & dwResult;
			bs & errmsg;
			bs & employees;
			bs & outReserve;
		    return bs.isGood();
		}
	    virtual void Dump(std::ostream& os)	{}
	
		virtual bool FromXML(const std::string& sXMLContent) { return true; }
		virtual bool ToXML(std::string& sXMLContent) { return true; }
	};
	class CEmployeeAoStub4App : public c2cent::CBaseStub4App, public IEmployeeAo,public IEmployeeAoAsyc{
		public:
			uint32_t AddEmployee(
				const CCntlInfo& rCntlInfo,
				const std::string& machineKey,
				const std::string& source,
				uint32_t sceneId,
				const erp::employee::po::CEmployeePo& employee,
				const std::string& inReserve,
				std::string& errmsg,
				erp::employee::po::CEmployeePo& employeeBack,
				std::string& outReserve
			);
			
			uint32_t SendAddEmployee(
				const CCntlInfo& rCntlInfo,
				const std::string& machineKey,
				const std::string& source,
				uint32_t sceneId,
				const erp::employee::po::CEmployeePo& employee,
				const std::string& inReserve
		    );
		    uint32_t RecvAddEmployee(
				const CCntlInfo& rCntlInfo,
				std::string& errmsg,
				erp::employee::po::CEmployeePo& employeeBack,
				std::string& outReserve
		    );
		    
		    uint32_t RecvAddEmployee(
		  		CCmdObj& rCmd,
				std::string& errmsg,
				erp::employee::po::CEmployeePo& employeeBack,
				std::string& outReserve
		    );
		    
		    uint32_t GetAddEmployeeRespCmd(
		    );
			uint32_t GetEmployeeById(
				const CCntlInfo& rCntlInfo,
				const std::string& machineKey,
				const std::string& source,
				uint32_t sceneId,
				const erp::employee::po::CEmployeeFilterPo& employeeFilter,
				const std::string& inReserve,
				std::string& errmsg,
				std::map<uint32_t,erp::employee::po::CEmployeePo >& employees,
				std::string& outReserve
			);
			
			uint32_t SendGetEmployeeById(
				const CCntlInfo& rCntlInfo,
				const std::string& machineKey,
				const std::string& source,
				uint32_t sceneId,
				const erp::employee::po::CEmployeeFilterPo& employeeFilter,
				const std::string& inReserve
		    );
		    uint32_t RecvGetEmployeeById(
				const CCntlInfo& rCntlInfo,
				std::string& errmsg,
				std::map<uint32_t,erp::employee::po::CEmployeePo >& employees,
				std::string& outReserve
		    );
		    
		    uint32_t RecvGetEmployeeById(
		  		CCmdObj& rCmd,
				std::string& errmsg,
				std::map<uint32_t,erp::employee::po::CEmployeePo >& employees,
				std::string& outReserve
		    );
		    
		    uint32_t GetGetEmployeeByIdRespCmd(
		    );
	};
	
	/**
	 *
 	 *  写入员工信息 
	 *
		 *@param String machineKey: 机器码，必填  				
		 *@param String source: 调用来源，必填  				
		 *@param uint32_t sceneId: 场景id，必填  				
		 *@param EmployeePo employee: 员工信息列表，必填  				
		 *@param String inReserve: 请求保留字  				
		 *@param String errmsg: 错误信息  		
		 *@param EmployeePo employeeBack: 员工信息列表，必填  		
		 *@param String outReserve: 返回保留字   		
     *
     *@return uint32_t : 0(成功) 其它失败
	 */	
	inline uint32_t CEmployeeAoStub4App::AddEmployee(
				const CCntlInfo& rCntlInfo,
				const std::string& machineKey,
				const std::string& source,
				uint32_t sceneId,
				const erp::employee::po::CEmployeePo& employee,
				const std::string& inReserve,
				std::string& errmsg,
				erp::employee::po::CEmployeePo& employeeBack,
				std::string& outReserve
	)
	{
		CAddEmployeeReq oReq;
			oReq.machineKey = machineKey;
			oReq.source = source;
			oReq.sceneId = sceneId;
			oReq.employee = employee;
			oReq.inReserve = inReserve;
			oReq.errmsg = errmsg;
			oReq.employeeBack = employeeBack;
			oReq.outReserve = outReserve;
	
		CCntlInfo* pCntlInfo = const_cast<CCntlInfo*>(&rCntlInfo);
	    m_pSvcCntl = reinterpret_cast<IServiceControl*>(pCntlInfo->getCntl());
	    if (m_pSvcCntl == NULL)
        {
            m_sErrMsg = "error, rCntlInfo is temporary variable";
            return 0xEE0041;
        }
	    int iRetCode = 0;
	    if((iRetCode = m_pSvcCntl->putSvcObj(&oReq, pCntlInfo->getRouteKey())) != 0)
	    {
	    	m_sErrMsg = "DoRequest failed.";
	        return iRetCode;
	    }
	
	    if((iRetCode = m_pSvcCntl->schedule()) != 0)
	    {
	        m_sErrMsg = "schedule failed.";
	        return 0xFFF2;
	    }
	    
	    CCmdObj& rCmd = m_pSvcCntl->getRespObj();
	    if(!rCmd.isValid(EMPLOYEEAO_ADDEMPLOYEE_RESP_CMD_ID))
	    {
	    	std::stringstream oss;
            oss << "Cmd not match: "
                << "expected cmd=" << std::hex << EMPLOYEEAO_ADDEMPLOYEE_RESP_CMD_ID << std::dec << " != "
                << "actualed cmd=" << std::hex << rCmd.getCmdId() << std::dec;
            m_sErrMsg = oss.str();
            return 0xEE0029;
	    }
	    
	    char* pBuf = NULL; uint32_t nLen = 0;
	    rCmd.getBuffer(pBuf, nLen);
	    CByteStreamNetwork bs(pBuf, nLen);
	    bs.isStoring(false);
	    
	    CAddEmployeeResp oResp;
	    if(!oResp.Serialize(bs))
	    {
	        m_sErrMsg = "Resp.Serialize(bs) failed";
	        return 0xEE0030;
	    }
			errmsg  = oResp.errmsg;
			employeeBack  = oResp.employeeBack;
			outReserve  = oResp.outReserve;
	    
	    return oResp.dwResult;
	}
	inline uint32_t CEmployeeAoStub4App::SendAddEmployee(
				const CCntlInfo& rCntlInfo,
				const std::string& machineKey,
				const std::string& source,
				uint32_t sceneId,
				const erp::employee::po::CEmployeePo& employee,
				const std::string& inReserve
	)
	{
	    CAddEmployeeReq oReq;
			oReq.machineKey = machineKey;
			oReq.source = source;
			oReq.sceneId = sceneId;
			oReq.employee = employee;
			oReq.inReserve = inReserve;
	
		CCntlInfo* pCntlInfo = const_cast<CCntlInfo*>(&rCntlInfo);
	    m_pSvcCntl = reinterpret_cast<IServiceControl*>(pCntlInfo->getCntl());
	    if (m_pSvcCntl == NULL)
        {
            m_sErrMsg = "error, rCntlInfo is temporary variable";
            return 0xEE0041;
        }
	    int iRetCode = 0;
	    if((iRetCode = m_pSvcCntl->putSvcObj(&oReq, pCntlInfo->getRouteKey())) != 0)
	    {
	    	m_sErrMsg = "DoRequest failed.";
	        return iRetCode;
	    }
		return 0;
	}
	inline uint32_t CEmployeeAoStub4App::RecvAddEmployee(
				const CCntlInfo& rCntlInfo,
				std::string& errmsg,
				erp::employee::po::CEmployeePo& employeeBack,
				std::string& outReserve
	)
	{
		CCntlInfo* pCntlInfo = const_cast<CCntlInfo*>(&rCntlInfo);
	    m_pSvcCntl = reinterpret_cast<IServiceControl*>(pCntlInfo->getCntl());
	    CCmdObj& rCmd = m_pSvcCntl->getRespObj();
	    if(!rCmd.isValid(EMPLOYEEAO_ADDEMPLOYEE_RESP_CMD_ID))
	    {
	    	std::stringstream oss;
            oss << "Cmd not match: "
                << "expected cmd=" << std::hex << EMPLOYEEAO_ADDEMPLOYEE_RESP_CMD_ID << std::dec << " != "
                << "actualed cmd=" << std::hex << rCmd.getCmdId() << std::dec;
            m_sErrMsg = oss.str();
	        return 0xEE0031;
	    }
	    
	    char* pBuf = NULL; uint32_t nLen = 0;
	    rCmd.getBuffer(pBuf, nLen);
	    CByteStreamNetwork bs(pBuf, nLen);
	    bs.isStoring(false);
	    
	    CAddEmployeeResp oResp;
	    if(!oResp.Serialize(bs))
	    {
	        m_sErrMsg = "Resp.Serialize(bs) failed";
	        return 0xEE0032;
	    }
			errmsg  = oResp.errmsg;
			employeeBack  = oResp.employeeBack;
			outReserve  = oResp.outReserve;
	    
	    return oResp.dwResult;
	}
	
	inline uint32_t CEmployeeAoStub4App::RecvAddEmployee(
		  		CCmdObj& rCmd,
				std::string& errmsg,
				erp::employee::po::CEmployeePo& employeeBack,
				std::string& outReserve
	)
	{	    
	    char* pBuf = NULL; uint32_t nLen = 0;
	    rCmd.getBuffer(pBuf, nLen);
	    CByteStreamNetwork bs(pBuf, nLen);
	    bs.isStoring(false);
	    
	    CAddEmployeeResp oResp;
	    if(!oResp.Serialize(bs))
	    {
	        m_sErrMsg = "Resp.Serialize(bs) failed";
	        return 0xEE0033;
	    }
			errmsg  = oResp.errmsg;
			employeeBack  = oResp.employeeBack;
			outReserve  = oResp.outReserve;
	    
	    return oResp.dwResult;
	}
	
	inline uint32_t CEmployeeAoStub4App::GetAddEmployeeRespCmd(
	)
	{	    
	    return EMPLOYEEAO_ADDEMPLOYEE_RESP_CMD_ID;
	}	
	/**
	 *
 	 *  根据ID获取员工信息 
	 *
		 *@param String machineKey: 机器码，必填  				
		 *@param String source: 调用来源，必填  				
		 *@param uint32_t sceneId: 场景id，必填  				
		 *@param EmployeeFilterPo employeeFilter: 过滤器，必填  				
		 *@param String inReserve: 请求保留字  				
		 *@param String errmsg: 错误信息  		
		 *@param Map employees: 员工信息  		
		 *@param String outReserve: 返回保留字   		
     *
     *@return uint32_t : 0(成功) 其它失败
	 */	
	inline uint32_t CEmployeeAoStub4App::GetEmployeeById(
				const CCntlInfo& rCntlInfo,
				const std::string& machineKey,
				const std::string& source,
				uint32_t sceneId,
				const erp::employee::po::CEmployeeFilterPo& employeeFilter,
				const std::string& inReserve,
				std::string& errmsg,
				std::map<uint32_t,erp::employee::po::CEmployeePo >& employees,
				std::string& outReserve
	)
	{
		CGetEmployeeByIdReq oReq;
			oReq.machineKey = machineKey;
			oReq.source = source;
			oReq.sceneId = sceneId;
			oReq.employeeFilter = employeeFilter;
			oReq.inReserve = inReserve;
			oReq.errmsg = errmsg;
			oReq.employees = employees;
			oReq.outReserve = outReserve;
	
		CCntlInfo* pCntlInfo = const_cast<CCntlInfo*>(&rCntlInfo);
	    m_pSvcCntl = reinterpret_cast<IServiceControl*>(pCntlInfo->getCntl());
	    if (m_pSvcCntl == NULL)
        {
            m_sErrMsg = "error, rCntlInfo is temporary variable";
            return 0xEE0041;
        }
	    int iRetCode = 0;
	    if((iRetCode = m_pSvcCntl->putSvcObj(&oReq, pCntlInfo->getRouteKey())) != 0)
	    {
	    	m_sErrMsg = "DoRequest failed.";
	        return iRetCode;
	    }
	
	    if((iRetCode = m_pSvcCntl->schedule()) != 0)
	    {
	        m_sErrMsg = "schedule failed.";
	        return 0xFFF2;
	    }
	    
	    CCmdObj& rCmd = m_pSvcCntl->getRespObj();
	    if(!rCmd.isValid(EMPLOYEEAO_GETEMPLOYEEBYID_RESP_CMD_ID))
	    {
	    	std::stringstream oss;
            oss << "Cmd not match: "
                << "expected cmd=" << std::hex << EMPLOYEEAO_GETEMPLOYEEBYID_RESP_CMD_ID << std::dec << " != "
                << "actualed cmd=" << std::hex << rCmd.getCmdId() << std::dec;
            m_sErrMsg = oss.str();
            return 0xEE0029;
	    }
	    
	    char* pBuf = NULL; uint32_t nLen = 0;
	    rCmd.getBuffer(pBuf, nLen);
	    CByteStreamNetwork bs(pBuf, nLen);
	    bs.isStoring(false);
	    
	    CGetEmployeeByIdResp oResp;
	    if(!oResp.Serialize(bs))
	    {
	        m_sErrMsg = "Resp.Serialize(bs) failed";
	        return 0xEE0030;
	    }
			errmsg  = oResp.errmsg;
			employees  = oResp.employees;
			outReserve  = oResp.outReserve;
	    
	    return oResp.dwResult;
	}
	inline uint32_t CEmployeeAoStub4App::SendGetEmployeeById(
				const CCntlInfo& rCntlInfo,
				const std::string& machineKey,
				const std::string& source,
				uint32_t sceneId,
				const erp::employee::po::CEmployeeFilterPo& employeeFilter,
				const std::string& inReserve
	)
	{
	    CGetEmployeeByIdReq oReq;
			oReq.machineKey = machineKey;
			oReq.source = source;
			oReq.sceneId = sceneId;
			oReq.employeeFilter = employeeFilter;
			oReq.inReserve = inReserve;
	
		CCntlInfo* pCntlInfo = const_cast<CCntlInfo*>(&rCntlInfo);
	    m_pSvcCntl = reinterpret_cast<IServiceControl*>(pCntlInfo->getCntl());
	    if (m_pSvcCntl == NULL)
        {
            m_sErrMsg = "error, rCntlInfo is temporary variable";
            return 0xEE0041;
        }
	    int iRetCode = 0;
	    if((iRetCode = m_pSvcCntl->putSvcObj(&oReq, pCntlInfo->getRouteKey())) != 0)
	    {
	    	m_sErrMsg = "DoRequest failed.";
	        return iRetCode;
	    }
		return 0;
	}
	inline uint32_t CEmployeeAoStub4App::RecvGetEmployeeById(
				const CCntlInfo& rCntlInfo,
				std::string& errmsg,
				std::map<uint32_t,erp::employee::po::CEmployeePo >& employees,
				std::string& outReserve
	)
	{
		CCntlInfo* pCntlInfo = const_cast<CCntlInfo*>(&rCntlInfo);
	    m_pSvcCntl = reinterpret_cast<IServiceControl*>(pCntlInfo->getCntl());
	    CCmdObj& rCmd = m_pSvcCntl->getRespObj();
	    if(!rCmd.isValid(EMPLOYEEAO_GETEMPLOYEEBYID_RESP_CMD_ID))
	    {
	    	std::stringstream oss;
            oss << "Cmd not match: "
                << "expected cmd=" << std::hex << EMPLOYEEAO_GETEMPLOYEEBYID_RESP_CMD_ID << std::dec << " != "
                << "actualed cmd=" << std::hex << rCmd.getCmdId() << std::dec;
            m_sErrMsg = oss.str();
	        return 0xEE0031;
	    }
	    
	    char* pBuf = NULL; uint32_t nLen = 0;
	    rCmd.getBuffer(pBuf, nLen);
	    CByteStreamNetwork bs(pBuf, nLen);
	    bs.isStoring(false);
	    
	    CGetEmployeeByIdResp oResp;
	    if(!oResp.Serialize(bs))
	    {
	        m_sErrMsg = "Resp.Serialize(bs) failed";
	        return 0xEE0032;
	    }
			errmsg  = oResp.errmsg;
			employees  = oResp.employees;
			outReserve  = oResp.outReserve;
	    
	    return oResp.dwResult;
	}
	
	inline uint32_t CEmployeeAoStub4App::RecvGetEmployeeById(
		  		CCmdObj& rCmd,
				std::string& errmsg,
				std::map<uint32_t,erp::employee::po::CEmployeePo >& employees,
				std::string& outReserve
	)
	{	    
	    char* pBuf = NULL; uint32_t nLen = 0;
	    rCmd.getBuffer(pBuf, nLen);
	    CByteStreamNetwork bs(pBuf, nLen);
	    bs.isStoring(false);
	    
	    CGetEmployeeByIdResp oResp;
	    if(!oResp.Serialize(bs))
	    {
	        m_sErrMsg = "Resp.Serialize(bs) failed";
	        return 0xEE0033;
	    }
			errmsg  = oResp.errmsg;
			employees  = oResp.employees;
			outReserve  = oResp.outReserve;
	    
	    return oResp.dwResult;
	}
	
	inline uint32_t CEmployeeAoStub4App::GetGetEmployeeByIdRespCmd(
	)
	{	    
	    return EMPLOYEEAO_GETEMPLOYEEBYID_RESP_CMD_ID;
	}	
		
}
}
}

#endif /* EMPLOYEEAO_STUB_4_APP_H */
